import type { FieldConfig } from '@/components/TableFilter.vue'
import { useShopStore } from '@/store/shopStore'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '統計月份',
    dataIndex: 'statMonth',
  },
  {
    title: '店舖',
    dataIndex: 'shop',
  },
  {
    title: '區域',
    dataIndex: 'region',
  },
  {
    title: '銷售金額',
    dataIndex: 'totalAmount',
  },
  {
    title: '佣金',
    dataIndex: 'totalCommission',
  },

  {
    title: '是否歸檔',
    dataIndex: 'isArchived',
  },
  // {
  //   title: '操作',
  //   key: 'action',
  //   align: 'center',
  // },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'stat_month',
    label: '銷售統計月份',
    type: 'date-picker',
    picker: 'month',
    placeholder: '請選擇銷售統計月份',
  },
  {
    name: 'shop_id',
    label: '店舖',
    type: 'select',
    placeholder: '請選擇店舖',
    options: [],
  },
]

export const getProcessFilterFields = async () => {
  const shopOptions = await useShopStore().fetchOptions()
  const shopField = filterFields.find((item) => item.name == 'shop_id')
  if (shopField) {
    shopField.options = shopOptions
  }
  return filterFields
}
